{
 "metadata": {
  "name": "",
  "signature": "sha256:3851c943c6508d4ce8237f71f8cabee83b3a407b48e0c40c4f42d7e5cc17db2e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "# Setting up Python\n",
      "\n",
      "## Short version for those familiar with Python\n",
      "\n",
      "The course materials use Python 3.4 along with the following packages and versions:\n",
      "\n",
      "    pandas                    0.15.2\n",
      "    patsy                     0.3.0\n",
      "    scipy                     0.15.1\n",
      "    seaborn                   0.5.1\n",
      "    statsmodels               0.6.1\n",
      "\n",
      "\n",
      "## Longer version\n",
      "\n",
      "We used Python 3.4 along with a number of additional packages in the course. This document specifies the steps needed to set up the environment on your computer. It assumes you have already installed the Anaconda Python distribution (Python 3.4) from [here](http://store.continuum.io/cshop/anaconda/).\n",
      "\n",
      "The Anaconda distribution is a set of software libraries, including the core Python language, something called the `conda` utility, and a number of additional libraries.\n",
      "\n",
      "The conda utility can manage the *libraries* (also called *packages* or *modules*, which are extensions to the Python language that allow for things like statistics) we want to use.\n",
      "\n",
      "### Checking that conda is working\n",
      "\n",
      "Linux / Mac OSX: Open a terminal (command prompt). \n",
      "\n",
      "Windows: type \"anaconda\" into the search field of the start menu and start the \"anaconda command prompt\"\n",
      "\n",
      "At the command line, type `conda list`, which should return a list of all the python packages in your default python environment. It might look something like this (longer list if you have used the default anaconda distribution):\n",
      "\n",
      "```\n",
      "conda                     3.7.4                    py34_0  \n",
      "openssl                   1.0.1j                        4  \n",
      "pip                       1.5.6                    py34_0  \n",
      "pycosat                   0.6.1                    py34_0  \n",
      "python                    3.4.2                         0  \n",
      "pyyaml                    3.11                     py34_0  \n",
      "readline                  6.2                           2  \n",
      "requests                  2.5.1                    py34_0  \n",
      "setuptools                3.6                      py34_0  \n",
      "sqlite                    3.8.4.1                       0  \n",
      "tk                        8.5.15                        0  \n",
      "xz                        5.0.5                         0  \n",
      "yaml                      0.1.4                         1  \n",
      "zlib                      1.2.7                         1  \n",
      "```\n",
      "\n",
      "The left column is the package name and the middle column is the package version. \n",
      "\n",
      "If this doesn't work for you (e.g. if the prompt reports that it doesn't know what `conda` is) then the anaconda distribution has not been correctly configured on your computer.\n",
      "\n",
      "You can find more information about the conda package manager [here](http://conda.pydata.org/index.html).\n",
      "\n",
      "\n",
      "### Upgrading packages\n",
      "\n",
      "Some of the packages installed by Anaconda aren't the most recent version available. We want to use the most recent versions where possible, so we're going to upgrade those packages manually using the `conda` tool (or `pip` if necessary, which is another tool that does essentially the same).\n",
      "\n",
      "For example, if you type `conda list` and look down the resulting list of packages, you'll see that the package `pandas` is version 0.14.1. We want to use the more recent 0.15.\n",
      "\n",
      "Now, type\n",
      "\n",
      "    conda install pandas\n",
      "\n",
      "this will report that we're upgrading `pandas` to version 0.15.2, and that to do this, a bunch of other packages will need to also be upgraded. One nice thing about using `conda` is that it will look after all these dependencies for us. \n",
      "\n",
      "Press `y` to proceed. Once these packages have downloaded and installed, we'll do the next one. I'm just going to write the install commands below. The procedure is the same as above.\n",
      "\n",
      "    conda install statsmodels\n",
      "    pip install ggplot\n",
      "    conda install seaborn\n",
      "    conda install ipython-notebook\n",
      "\n",
      "That should be it! If all the steps above proceeded successfully, everyone in the course should now be using the same package versions. That means that when we find bugs (we probably will), at least they're the same for everyone.\n",
      "\n",
      "To check, type `conda list` again. Look down the list. You should be using the following versions: \n",
      "\n",
      "    pandas                    0.15.2\n",
      "    patsy                     0.3.0\n",
      "    scipy                     0.15.1\n",
      "    seaborn                   0.5.1\n",
      "    statsmodels               0.6.1\n"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## The IPython notebook\n",
      "\n",
      "There are a number of different ways to use Python for data analysis. In this course we will encourage you to use the IPython Notebook. \n",
      "\n",
      "### Starting the notebook server\n",
      "\n",
      "Linux / Mac OSX: open the Anaconda Launcher, and click \"IPython Notebook\".\n",
      "\n",
      "Windows: type ipython notebook into the start menu search field, and click \"IPython Notebook\".\n",
      "\n",
      "The IPython Notebook is a file format (extension .ipynb) that allows you to integrate text, code and figures into a single document. You view the document using a web browser, and it can be exported into formats like html and pdf, if you want to give people a static (i.e. not interactive) document.\n",
      "\n",
      "Think of the Notebook like a lab notebook: you can write down some ideas about what you want to do and how you want to do it. The advantage of using this electronic format, though, is that you can now include the code that run your analysis and the outputs that result. It becomes a living, interactive document. \n",
      "\n",
      "Take some time to familiarise yourself with the notebook. You can find many tutorials online. For example, try [this](http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Notebook/Running%20Code.ipynb), [this](https://opentechschool.github.io/python-data-intro/core/notebook.html) or [this](https://www.youtube.com/watch?v=DUCQ_HZamhs). Note that you can skip all the \"installing python\" steps, since we've done that already. You can also see [this page](https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks#introductory-tutorials) for a list of interesting ipython notebooks available on the web.\n",
      "\n",
      "We will be providing you with some example notebook files that you will be able to run. During the course you will work on your own notebooks for data analysis. Feel free to copy code from our notebooks into yours."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Packages and documentation\n",
      "\n",
      "During the course we will use a number of packages to analyse data in Python. These are all open source packages, maintained and developed by teams of volunteers around the world. You can find all the documentation for any package we're using by doing a web search for the package names. \n",
      "\n",
      "The main packages we will use are [Pandas](http://pandas.pydata.org/pandas-docs/stable/index.html), [statsmodels](http://statsmodels.sourceforge.net/stable/index.html), and for plotting, [Seaborn](http://stanford.edu/~mwaskom/software/seaborn/). If you are having trouble with commands from the packages we're using, refer there for help first."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from IPython.core.display import HTML\n",
      "\n",
      "\n",
      "def css_styling():\n",
      "    styles = open(\"custom_style.css\", \"r\").read()\n",
      "    return HTML(styles)\n",
      "css_styling()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<style>\n",
        "    @font-face {\n",
        "        font-family: \"Computer Modern\";\n",
        "        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunss.otf');\n",
        "    }\n",
        "    @font-face {\n",
        "        font-family: \"Computer Modern\";\n",
        "        font-weight: bold;\n",
        "        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunsx.otf');\n",
        "    }\n",
        "    @font-face {\n",
        "        font-family: \"Computer Modern\";\n",
        "        font-style: oblique;\n",
        "        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunsi.otf');\n",
        "    }\n",
        "    @font-face {\n",
        "        font-family: \"Computer Modern\";\n",
        "        font-weight: bold;\n",
        "        font-style: oblique;\n",
        "        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunso.otf');\n",
        "    }\n",
        "    div.cell{\n",
        "        width:850px;\n",
        "        font-size: 11pt;\n",
        "        margin-left:16% !important;\n",
        "        margin-right:auto;\n",
        "    }\n",
        "    h1 {\n",
        "        font-family: Minion Pro, serif;\n",
        "    }\n",
        "    h2 {\n",
        "        font-family: Minion Pro, serif;\n",
        "    }\n",
        "    h3 {\n",
        "        font-family: Minion Pro, serif;\n",
        "    }\n",
        "    h4{\n",
        "        margin-top:12px;\n",
        "        margin-bottom: 3px;\n",
        "       }\n",
        "    div.text_cell_render{\n",
        "        font-family: Optima, sans-serif;\n",
        "        line-height: 145%;\n",
        "        font-size: 12pt;\n",
        "        width:850px;\n",
        "        margin-left:auto;\n",
        "        margin-right:auto;\n",
        "    }\n",
        "    .CodeMirror{\n",
        "            font-family: \"Source Code Pro\", source-code-pro,Consolas, monospace;\n",
        "    }\n",
        "    .prompt{\n",
        "        display: None;\n",
        "    }\n",
        "    .text_cell_render h5 {\n",
        "        font-weight: 300;\n",
        "        font-size: 12pt;\n",
        "        color: #4057A1;\n",
        "        font-style: italic;\n",
        "        margin-bottom: .5em;\n",
        "        margin-top: 0.5em;\n",
        "        display: block;\n",
        "    }\n",
        "\n",
        "    .warning{\n",
        "        color: rgb( 240, 20, 20 )\n",
        "        }\n",
        "</style>\n",
        "<script>\n",
        "    MathJax.Hub.Config({\n",
        "                        TeX: {\n",
        "                           extensions: [\"AMSmath.js\"]\n",
        "                           },\n",
        "                tex2jax: {\n",
        "                    inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
        "                    displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
        "                },\n",
        "                displayAlign: 'center', // Change this to 'center' to center equations.\n",
        "                \"HTML-CSS\": {\n",
        "                    styles: {'.MathJax_Display': {\"margin\": 4}}\n",
        "                }\n",
        "        });\n",
        "</script>"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 1,
       "text": [
        "<IPython.core.display.HTML at 0x106e0dd30>"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}